<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0, width=device-width"/>
    <title>api</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
  
    <link rel="stylesheet" type="text/css" href="../css/base.css" />

</head>
    <style type="text/css">
    html,body{
    	background: #fff;
    }
    	.g-pay-success {
		    padding: 0 5px 10px;
		}
		.clearfix {
		    display: block;
		}
		.g-pay-auto {
		    display: block;
		    margin: 0 auto;
		    text-align: center;
		}
		.z-pay-tips {
		    text-align: left;
		    margin: 20px auto;
		    display: inline-block;
		}
		
		
		.z-pay-tips s, .z-pay-tips i {
		
		    width: 20px;
		    height: 22px;
		    display: inline-block;
		    margin: -1px 5px 0 0;
		    float: left;
		}
		
		.z-pay-tips s{
		    background: url('http://wap.jqmao.cn/staticsmwap/templates/yungou/images/mobile/setIcon.png');
		    background-size: 80px auto;
		}
.z-pay-tips s {
   		 background-position: 0 -28px;
		}
		.u-Btn {
    color: #fff;
    text-align: center;
    font-size: 14px;
    display: box;
    display: -webkit-box;
    display: -moz-box;
}
.g-pay-success .u-Btn-li {
    width: 50%;
}
.u-Btn .u-Btn-li {
    font-size: 18px;
    -webkit-box-flex: 1;
    -moz-box-flex: 1;
    box-flex: 1;
    text-align: center;
}
.g-pay-success .u-Btn-li {
    width: 50%;
}
.u-Btn .u-Btn-li {
    font-size: 18px;
    -webkit-box-flex: 1;
    -moz-box-flex: 1;
    box-flex: 1;
    text-align: center;
}
.u-Btn a.z-CloseBtn {
    color: #FF0000;
    font-size: 14px;
    line-height: 33px;
    border: 1px solid #DDD;
    margin-right: 10px;
    background: #fff;
    
}
.u-Btn a.z-DefineBtn {
    color: #fff;
    font-size: 14px;
    line-height: 33px;
    border: 1px solid #FE6D0B;
   
    background: #FF0000;
}
a.z-CloseBtn, a.z-DefineBtn, a.z-ShoppingBtn, a.z-cartBtn {
    line-height: 44px;
    text-align: center;
    display: block;
    border-radius: 3px;
}

     
    </style>

</head>
<body>
    <header id='header'>
        <div class="header"> <i id='back' class="back" onclick="_back()"></i>
            <h1>支付结果</h1>
        </div>
    </header>
    <script id='result-template' type="text/x-dot-template">
        
    </script>
    <div class="content" id='result-detail'>
  		<section id="shopResultBox" class="clearfix g-pay-success">
        <div class="g-pay-auto">
            <div class="z-pay-tips"><s></s><b><em id='em' class="gray6">恭喜您,支付成功</em></b></div>
        </div>
           <div>
            <p style="text-align: center;font-size: 14px" class="gray6">请及时填写收货地址,以便于获奖后为您寄出</p>
            <p id="red" style="line-height: 1.5em; text-align: center; display: none">
                <img style="height: 80%; width: 80%; text-align: center" src="http://wap.jqmao.cn/staticsmwap/templates/yungou/images/mobile/4699872274697143729.jpg">
            </p>

            <br>
        </div>
        <div class="u-Btn">
            <div class="u-Btn-li" id='buyRecord' ><a class="z-CloseBtn">查看猫购记录</a></div>
            <div class="u-Btn-li" style="display: none" id='recharge' onclick="openWin('account')" ><a class="z-CloseBtn">查看充值记录</a></div>
            <div class="u-Btn-li" id='buyGo'><a class="z-DefineBtn">继续购物</a></div>
        </div>
    </section>
    </div>

</body>
    <script type="text/javascript" src="../script/zepto.min.js"></script>

    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/doT.min.js"></script>
    <script type="text/javascript" src="../script/common.js"></script>
  
    <script type="text/javascript">
   

    apiready = function(){
    setTimeout(function(){
    	api.closeWin({
	    	name:'order'
	    });
    },1000);
    
    
   	
	headerstatus();
	
	
    var buyRecord = $api.byId('buyRecord');
    var buyGo = $api.byId('buyGo');
    var uid = $api.getStorage('user').uid;
    $api.addEvt(buyRecord, 'click', function(){
    	openWin('myBuyRecord',''+uid);
    });
    $api.addEvt(buyGo, 'click', function(){
    	api.closeToWin({
	        name: 'root'
        });
        backmain()
    });
    setTimeout(clean,0);
    $api.setStorage('ShoppingCart','');
    var recharge = api.pageParam.recharge;
    if(recharge!=undefined){
    	$api.html($api.byId('em'), '恭喜您,充值成功');
    	$api.css($api.byId('recharge'),'display:block');
    	$api.css($api.byId('buyRecord'),'display:none');
    	
    }

    var r_code = api.pageParam.r_code;
    //alert(r_code)
    
    if(r_code!=undefined){
    var systemType = api.systemType;
							
	if(systemType=='ios'){
		api.ajax({
		    url:'http://wap.jqmao.cn/hide'
	    },function(ret,err){
	    	//coding...
	    	//alert(ret.value)
	    	if(ret.value=='1'){
	    	//alert(ret.value)
	  
	    	}else{
	    	 var red = $api.byId('red');
	    $api.css(red,'display:block');
	    	}
	    });
	}else{
		 var red = $api.byId('red');
	    $api.css(red,'display:block');
	}
    
   
    	//alert(r_code)
    	$api.addEvt($api.byId('red'), 'click', function(){
    	var dialogBox = api.require('dialogBox');
dialogBox.raffle ({
    texts: {
               
        mainText: '恭喜获得10个红包',    
        subText: '分享给小伙伴，大家一起抢',    
        leftTitle: '取消',   
        rightTitle: '分享'   
    },
    styles: {
        bg: '#fff',               
        w: 300,                     
        
        icon:{         
            marginT: 20,           
            w: 100,                 
            h: 100,               
            iconPath:'widget://image/share/redshare.png'           
        },
        main: {                   
            marginT: 20,          
            color: '#636363',      
            size: 14            
        },
        sub: {                     
            marginT: 8,      
            color: '#999999',
            size: 12   
        },
        left:{      
            marginB: 7,
            marginL: 18,
            w: 130,
            h: 35,
            corner: 2,        
            bg: '#fff',     
            color: '#007FFF',
            size: 12
        },
        right: {    
            marginB: 7,   
            marginL: 18,
            w: 130,  
            h: 35,   
            corner: 2,  
            bg: '#fff',
            color: '#007FFF',  
            size: 12              
        }
    }
}, function(ret, err){
    if( ret ){
	    if(ret.eventType=='right'){
	    dialogBox.close ({
		    	dialogName: 'raffle'
			});
	    	 dialogBox.actionMenu ({
    rect:{
        h: 150
    },
    texts:{
         cancel: '取消'
    },
    items:[
    {
        text: '微信朋友圈',
        icon: 'widget://image/share/pengyouquan.png'
    },
    {
        text: '微信好友',
        icon: 'widget://image/share/weixinhaoyou.png'
    },
    {
        text: 'QQ好友',
        icon: 'widget://image/share/qqhaoyou.png'
    },
    {
        text: 'QQ空间',
        icon: 'widget://image/share/qqkongjian.png'
    }
    ],
    styles:{
        bg:'#FFF',
        column: 4,
        itemText: {
            color: '#000',
            size: 12,
            marginT:8
        },
        itemIcon:{
            size:50
        },
        cancel:{  
            bg: 'fs://icon.png',   
            color:'#000',          
            h: 44 ,                 
            size: 14       
        }
    },
    tapClose:true
}, function(ret){

    //alert(JSON.stringify(ret));
    
    if(ret.eventType=='cancel'){
    	
		    dialogBox.close ({
		    	dialogName: 'actionMenu'
			});
    }else{
    	if(ret.index==0){
    	var wx = api.require('wx');
    	wx.isInstalled(function(ret, err) {
    if (ret.installed) {
        //alert("当前设备已安装微信客户端");
        
    } else {
        alert('当前设备未安装微信客户端');
        return false;
    }
});
    		wx.shareWebpage({
			    apiKey: '',
			    scene: 'timeline',
			    title: '红包来袭，助你轻松猫购',
			    description: '红包分享根本停不下来啊，见者都有份，一起来抢smart！！！',
			     thumb: 'widget://image/share/redshare.png',
			    contentUrl: 'http://wap.jqmao.cn/mobile/redPacket/shareCoupon/'+r_code
			}, function(ret, err){
			    if(ret.status){
			       toast('分享成功')
			    }else{
			        if(err.code==2){
			        	toast('取消分享')
			        }
			    }
			});
    	}else if(ret.index==1){
    	var wx = api.require('wx');
    	wx.isInstalled(function(ret, err) {
    if (ret.installed) {
        //alert("当前设备已安装微信客户端");
        
    } else {
        alert('当前设备未安装微信客户端');
        return false;
    }
});
    		wx.shareWebpage({
			    apiKey: '',
			    scene: 'session',
			    title: '红包来袭，助你轻松猫购',
			    description: '红包分享根本停不下来啊，见者都有份，一起来抢smart！！！',
			    thumb: 'widget://image/share/redshare.png',
			     contentUrl: 'http://wap.jqmao.cn/mobile/redPacket/shareCoupon/'+r_code
			}, function(ret, err){
			    if(ret.status){
			       toast('分享成功')
			    }else{
			        if(err.code==2){
			        	toast('取消分享')
			        }
			    }
			});
    	
    	}else if(ret.index==2){
    		var qq = api.require('qq');
    		qq.installed(function(ret, err) {
			    if (ret.status) {
			        //api.alert({ msg: "安装" });
			    } else {
			        api.alert({ msg: "没有安装qq客户端" });
			        return false;
			    }
				});
				qq.shareNews({
				    url:'http://wap.jqmao.cn/mobile/redPacket/shareCoupon/'+r_code,
				   title: '红包来袭，助你轻松猫购',
							    description: '红包分享根本停不下来啊，见者都有份，一起来抢smart！！！',
				    imgUrl:'widget://image/share/1111.jpg',
				    type:'QFriend'
				});
    	}else if(ret.index==3){
    			var qq = api.require('qq');
    			qq.installed(function(ret, err) {
			    if (ret.status) {
			        //api.alert({ msg: "安装" });
			    } else {
			        api.alert({ msg: "没有安装qq客户端" });
			        return false;
			    }
				});
qq.shareNews({
    url:'http://wap.jqmao.cn/mobile/redPacket/shareCoupon/'+r_code,
   title: '红包来袭，助你轻松猫购',
			    description: '红包分享根本停不下来啊，见者都有份，一起来抢smart！！！',
    imgUrl:'http://wap.jqmao.cn/staticsmwap/templates/yungou/images/1111.jpg',
    type:'QZone'
},function(ret,err){
	if(ret.status){
			       toast('分享成功')
			    }else{
			      if(err.code==-4){
			        	toast('取消分享')
			        }
			        	
			        
			    }
});
    	}
    }
});
	    }else{
	    	dialogBox.close ({
		    	dialogName: 'raffle'
			});
	    }
       
    }else{
        //alert(JSON.stringify(err));
    }
});
      		

    	});
    	
    }
    
	    api.addEventListener({
	    name:'keyback'
		}, function(ret, err){      
		     _back()
		});
    }
  function _back(){
	    api.closeWin({
	    	name:'order'
	    });
            api.historyBack({
            frameName:''
        },function(ret,err){
            if(!ret.status){
            api.execScript({
            name:'root',
            frameName: 'user',
            script: 'userReload()'
        });
                api.closeWin();
            }
        });
        }
        
        function clean(){
       
        	api.execScript({
        name: 'root',
        frameName: 'cart',
        script: 'cartClean()'
    });
        }
    </script>

</html>
